<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <title>文章列表 - 爱美文网</title>
        <link rel="stylesheet" href="/layui/dist/css/layui.css">
        <style type="text/css">
            .layui-table-cell {
                height: auto !important;
            }
            .post_item {
                text-decoration: underline #009688 dashed !important;
            }
        </style>
    </head>
    <body class="layui-layout-body">
        <div class="layui-layout layui-layout-admin">
            <?php require TPL_PATH . 'admin/header.html'; ?>
            <div class="layui-body">
                <div style="width: 95%; padding: 10px;">
                    <!-- 内容主体区域 -->
                    <fieldset class="layui-elem-field">
                        <legend>文章列表</legend>
                        <form class="layui-form layui-form-pane" style="padding: 20px 1px 1px 20px;">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">标题</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="title" class="layui-input" placeholder="文章标题|模糊匹配" />
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">作者</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="author" class="layui-input" placeholder="文章作者" />
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">分类</label>
                                    <div class="layui-input-inline">
                                        <select name="category">
                                            <option value="">全部</option>
                                            <?php foreach (\Config\System::$category as $k => $v): ?>
                                            <option value="<?=$k?>"><?=$v?></option>
                                            <?php endforeach; ?>
                                        </select>     
                                    </div>
                                </div>

                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">文章状态</label>
                                    <div class="layui-input-inline">
                                        <select name="status">
                                            <option value="">全部</option>
                                            <option value="1">显示</option>
                                            <option value="0">隐藏</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <button class="layui-btn" lay-submit lay-filter="*">查询</button></div>
                            </div>
                        </form>
                        <div style="padding: 0px 10px 5px 20px;">
                            <table id="data_list" lay-filter="data_list"></table>
                        </div>
                    </fieldset>
                </div>
            </div>
            <?php require TPL_PATH . 'admin/footer.html'; ?>
        </div>
        <script src="/layui/dist/layui.js"></script>
        <script>
            layui.use(['element', 'form', 'jquery', 'table'], function () {
                var element = layui.element, form = layui.form, $ = layui.$, table = layui.table;
                $('form')[0].reset();
                table.render({
                    elem: '#data_list',
                    height: 'auto',
                    page: true,
                    loading: true,
                    id: 'data_list',
                    url: '/admin/post/search',
                    method: 'post',
                    limits: [20, 50],
                    limit: 20,
                    cols: [[
                            {field: 'id', title: 'ID', width: 80, align: 'center'},
                            {field: 'thumb', title: '封面图', width: 150, align: 'center'},
                            {field: 'title', title: '标题', width: 260, align: 'center'},
                            {field: 'author', title: '作者', width: 120, align: 'center'},
                            {field: 'category', title: '分类', width: 120, align: 'center'},
                            {field: 'status', title: '状态', width: 100, align: 'center'},
                            {field: 'views', title: '浏览量', width: 100, align: 'center'},
                            {field: 'op_string', title: '操作', align: 'left'}
                        ]]
                });

                form.on('submit(*)', function (data) {
                    table.reload('data_list', {
                        where: data.field,
                        page: {
                            curr: 1
                        }
                    });
                    return false;
                });
            });
        </script>
    </body>
</html>